home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / glib-2.0 / gobject / gsignal.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-25  |  10.2 KB  |  271 lines

  1. /* GObject - GLib Type, Object, Parameter and Signal Library
  2.  * Copyright (C) 2000-2001 Red Hat, Inc.
  3.  *
  4.  * This library is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU Lesser General Public
  6.  * License as published by the Free Software Foundation; either
  7.  * version 2 of the License, or (at your option) any later version.
  8.  *
  9.  * This library is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the GNU
  12.  * Lesser General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU Lesser General
  15.  * Public License along with this library; if not, write to the
  16.  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  17.  * Boston, MA 02111-1307, USA.
  18.  */
  19. #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
  20. #error "Only <glib-object.h> can be included directly."
  21. #endif
  22.  
  23. #ifndef __G_SIGNAL_H__
  24. #define __G_SIGNAL_H__
  25.  
  26. #include    <gobject/gclosure.h>
  27. #include    <gobject/gvalue.h>
  28. #include    <gobject/gparam.h>
  29. #include    <gobject/gmarshal.h>
  30.  
  31. G_BEGIN_DECLS
  32.  
  33. /* --- typedefs --- */
  34. typedef struct _GSignalQuery         GSignalQuery;
  35. typedef struct _GSignalInvocationHint     GSignalInvocationHint;
  36. typedef GClosureMarshal             GSignalCMarshaller;
  37. typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint,
  38.                      guint            n_param_values,
  39.                      const GValue           *param_values,
  40.                      gpointer        data);
  41. typedef gboolean (*GSignalAccumulator)    (GSignalInvocationHint *ihint,
  42.                      GValue               *return_accu,
  43.                      const GValue           *handler_return,
  44.                      gpointer               data);
  45.  
  46.  
  47. /* --- run, match and connect types --- */
  48. typedef enum
  49. {
  50.   G_SIGNAL_RUN_FIRST    = 1 << 0,
  51.   G_SIGNAL_RUN_LAST    = 1 << 1,
  52.   G_SIGNAL_RUN_CLEANUP    = 1 << 2,
  53.   G_SIGNAL_NO_RECURSE    = 1 << 3,
  54.   G_SIGNAL_DETAILED    = 1 << 4,
  55.   G_SIGNAL_ACTION    = 1 << 5,
  56.   G_SIGNAL_NO_HOOKS    = 1 << 6
  57. } GSignalFlags;
  58. #define G_SIGNAL_FLAGS_MASK  0x7f
  59. typedef enum
  60. {
  61.   G_CONNECT_AFTER    = 1 << 0,
  62.   G_CONNECT_SWAPPED    = 1 << 1
  63. } GConnectFlags;
  64. typedef enum
  65. {
  66.   G_SIGNAL_MATCH_ID       = 1 << 0,
  67.   G_SIGNAL_MATCH_DETAIL       = 1 << 1,
  68.   G_SIGNAL_MATCH_CLOSURE   = 1 << 2,
  69.   G_SIGNAL_MATCH_FUNC       = 1 << 3,
  70.   G_SIGNAL_MATCH_DATA       = 1 << 4,
  71.   G_SIGNAL_MATCH_UNBLOCKED = 1 << 5
  72. } GSignalMatchType;
  73. #define G_SIGNAL_MATCH_MASK  0x3f
  74. #define    G_SIGNAL_TYPE_STATIC_SCOPE (G_TYPE_FLAG_RESERVED_ID_BIT)
  75.  
  76.  
  77. /* --- signal information --- */
  78. struct _GSignalInvocationHint
  79. {
  80.   guint        signal_id;
  81.   GQuark    detail;
  82.   GSignalFlags    run_type;
  83. };
  84. struct _GSignalQuery
  85. {
  86.   guint        signal_id;
  87.   const gchar  *signal_name;
  88.   GType        itype;
  89.   GSignalFlags    signal_flags;
  90.   GType        return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
  91.   guint        n_params;
  92.   const GType  *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
  93. };
  94.  
  95.  
  96. /* --- signals --- */
  97. guint                 g_signal_newv         (const gchar        *signal_name,
  98.                          GType               itype,
  99.                          GSignalFlags        signal_flags,
  100.                          GClosure           *class_closure,
  101.                          GSignalAccumulator     accumulator,
  102.                          gpointer         accu_data,
  103.                          GSignalCMarshaller  c_marshaller,
  104.                          GType               return_type,
  105.                          guint               n_params,
  106.                          GType              *param_types);
  107. guint                 g_signal_new_valist   (const gchar        *signal_name,
  108.                          GType               itype,
  109.                          GSignalFlags        signal_flags,
  110.                          GClosure           *class_closure,
  111.                          GSignalAccumulator     accumulator,
  112.                          gpointer         accu_data,
  113.                          GSignalCMarshaller  c_marshaller,
  114.                          GType               return_type,
  115.                          guint               n_params,
  116.                          va_list             args);
  117. guint                 g_signal_new          (const gchar        *signal_name,
  118.                          GType               itype,
  119.                          GSignalFlags        signal_flags,
  120.                          guint               class_offset,
  121.                          GSignalAccumulator     accumulator,
  122.                          gpointer         accu_data,
  123.                          GSignalCMarshaller  c_marshaller,
  124.                          GType               return_type,
  125.                          guint               n_params,
  126.                          ...);
  127. void                  g_signal_emitv        (const GValue       *instance_and_params,
  128.                          guint               signal_id,
  129.                          GQuark              detail,
  130.                          GValue             *return_value);
  131. void                  g_signal_emit_valist  (gpointer            instance,
  132.                          guint               signal_id,
  133.                          GQuark              detail,
  134.                          va_list             var_args);
  135. void                  g_signal_emit         (gpointer            instance,
  136.                          guint               signal_id,
  137.                          GQuark              detail,
  138.                          ...);
  139. void                  g_signal_emit_by_name (gpointer            instance,
  140.                          const gchar        *detailed_signal,
  141.                          ...);
  142. guint                 g_signal_lookup       (const gchar        *name,
  143.                          GType               itype);
  144. G_CONST_RETURN gchar* g_signal_name         (guint               signal_id);
  145. void                  g_signal_query        (guint               signal_id,
  146.                          GSignalQuery       *query);
  147. guint*                g_signal_list_ids     (GType               itype,
  148.                          guint              *n_ids);
  149. gboolean          g_signal_parse_name   (const gchar    *detailed_signal,
  150.                          GType         itype,
  151.                          guint        *signal_id_p,
  152.                          GQuark        *detail_p,
  153.                          gboolean         force_detail_quark);
  154. GSignalInvocationHint* g_signal_get_invocation_hint (gpointer    instance);
  155.  
  156.  
  157. /* --- signal emissions --- */
  158. void    g_signal_stop_emission            (gpointer          instance,
  159.                          guint          signal_id,
  160.                          GQuark          detail);
  161. void    g_signal_stop_emission_by_name        (gpointer          instance,
  162.                          const gchar     *detailed_signal);
  163. gulong    g_signal_add_emission_hook        (guint          signal_id,
  164.                          GQuark          detail,
  165.                          GSignalEmissionHook  hook_func,
  166.                          gpointer                 hook_data,
  167.                          GDestroyNotify      data_destroy);
  168. void    g_signal_remove_emission_hook        (guint          signal_id,
  169.                          gulong          hook_id);
  170.  
  171.  
  172. /* --- signal handlers --- */
  173. gboolean g_signal_has_handler_pending          (gpointer          instance,
  174.                            guint          signal_id,
  175.                            GQuark          detail,
  176.                            gboolean          may_be_blocked);
  177. gulong     g_signal_connect_closure_by_id          (gpointer          instance,
  178.                            guint          signal_id,
  179.                            GQuark          detail,
  180.                            GClosure         *closure,
  181.                            gboolean          after);
  182. gulong     g_signal_connect_closure          (gpointer          instance,
  183.                            const gchar       *detailed_signal,
  184.                            GClosure         *closure,
  185.                            gboolean          after);
  186. gulong     g_signal_connect_data              (gpointer          instance,
  187.                            const gchar     *detailed_signal,
  188.                            GCallback      c_handler,
  189.                            gpointer          data,
  190.                            GClosureNotify      destroy_data,
  191.                            GConnectFlags      connect_flags);
  192. void     g_signal_handler_block              (gpointer          instance,
  193.                            gulong          handler_id);
  194. void     g_signal_handler_unblock          (gpointer          instance,
  195.                            gulong          handler_id);
  196. void     g_signal_handler_disconnect          (gpointer          instance,
  197.                            gulong          handler_id);
  198. gboolean g_signal_handler_is_connected          (gpointer          instance,
  199.                            gulong          handler_id);
  200. gulong     g_signal_handler_find              (gpointer          instance,
  201.                            GSignalMatchType      mask,
  202.                            guint          signal_id,
  203.                            GQuark          detail,
  204.                            GClosure         *closure,
  205.                            gpointer          func,
  206.                            gpointer          data);
  207. guint     g_signal_handlers_block_matched      (gpointer          instance,
  208.                            GSignalMatchType      mask,
  209.                            guint          signal_id,
  210.                            GQuark          detail,
  211.                            GClosure         *closure,
  212.                            gpointer          func,
  213.                            gpointer          data);
  214. guint     g_signal_handlers_unblock_matched    (gpointer          instance,
  215.                            GSignalMatchType      mask,
  216.                            guint          signal_id,
  217.                            GQuark          detail,
  218.                            GClosure         *closure,
  219.                            gpointer          func,
  220.                            gpointer          data);
  221. guint     g_signal_handlers_disconnect_matched (gpointer          instance,
  222.                            GSignalMatchType      mask,
  223.                            guint          signal_id,
  224.                            GQuark          detail,
  225.                            GClosure         *closure,
  226.                            gpointer          func,
  227.                            gpointer          data);
  228.  
  229.  
  230. /* --- chaining for language bindings --- */
  231. void    g_signal_override_class_closure          (guint          signal_id,
  232.                            GType          instance_type,
  233.                            GClosure         *class_closure);
  234. void    g_signal_chain_from_overridden          (const GValue      *instance_and_params,
  235.                            GValue            *return_value);
  236.  
  237.  
  238. /* --- convenience --- */
  239. #define g_signal_connect(instance, detailed_signal, c_handler, data) \
  240.     g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
  241. #define g_signal_connect_after(instance, detailed_signal, c_handler, data) \
  242.     g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_AFTER)
  243. #define g_signal_connect_swapped(instance, detailed_signal, c_handler, data) \
  244.     g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_SWAPPED)
  245. #define    g_signal_handlers_disconnect_by_func(instance, func, data)                        \
  246.     g_signal_handlers_disconnect_matched ((instance),                                \
  247.                       (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA),    \
  248.                       0, 0, NULL, (func), (data))
  249. #define    g_signal_handlers_block_by_func(instance, func, data)                            \
  250.     g_signal_handlers_block_matched      ((instance),                                \
  251.                           (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA),    \
  252.                           0, 0, NULL, (func), (data))
  253. #define    g_signal_handlers_unblock_by_func(instance, func, data)                            \
  254.     g_signal_handlers_unblock_matched    ((instance),                                \
  255.                           (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA),    \
  256.                           0, 0, NULL, (func), (data))
  257.  
  258.  
  259. gboolean g_signal_accumulator_true_handled (GSignalInvocationHint *ihint,
  260.                         GValue                *return_accu,
  261.                         const GValue          *handler_return,
  262.                         gpointer               dummy);
  263.  
  264. /*< private >*/
  265. void     g_signal_handlers_destroy          (gpointer          instance);
  266. void     _g_signals_destroy              (GType          itype);
  267.  
  268. G_END_DECLS
  269.  
  270. #endif /* __G_SIGNAL_H__ */
  271.